﻿
namespace Rex.Assignment.Common
{
    /// <summary>
    /// 返回参数
    /// </summary>
    /// <remarks>
    /// @创 建 者：Rex
    /// @创建日期：2021/2/21 14:44:38
    /// </remarks>
    public class DataResult<T>
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public StatusCode Code { get; set; }

        /// <summary>
        /// 消息提示
        /// </summary>
        public string Msg { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public int Count { get; set; }

        /// <summary>
        /// 数据
        /// </summary>
        public T Data { get; set; }

        public DataResult()
        {
            this.Code = StatusCode.Succees;
        }

        /// <summary>
        /// 设置数据信息
        /// </summary>
        /// <param name="Code">状态码</param>
        /// <param name="Msg">消息提示</param>
        public DataResult(StatusCode Code, string Msg)
        {
            this.Code = Code;
            this.Msg = Msg;
        }

        /// <summary>
        /// 设置数据信息
        /// </summary>
        /// <param name="Code">状态码</param>
        /// <param name="Msg">消息提示</param>
        /// <param name="Count">总数量</param>
        /// <param name="Data">数据集</param>
        public DataResult(StatusCode Code, string Msg, int Count, T Data)
        {
            this.Code = Code;
            this.Msg = Msg;
            this.Count = Count;
            this.Data = Data;
        }

        /// <summary>
        /// 设置数据信息
        /// </summary>
        /// <param name="Code">状态码</param>
        /// <param name="Msg">消息提示</param>
        public void SetDataResult(StatusCode Code, string Msg)
        {
            this.Code = Code;
            this.Msg = Msg;
        }

        /// <summary>
        /// 设置数据信息
        /// </summary>
        /// <param name="Code">状态码</param>
        /// <param name="Msg">消息提示</param>
        /// <param name="Count">总数量</param>
        /// <param name="Data">数据集</param>
        public void SetDataResult(StatusCode Code, string Msg, int Count, T Data)
        {
            this.Code = Code;
            this.Msg = Msg;
            this.Count = Count;
            this.Data = Data;
        }
    }
}
